/**
 * Created by NMTuan on 2016/10/10.
 */

//正则表达式

hgNews.regExp = {};

/**
 * 验证手机号
 * @param phoneNumber   待验证的手机号, 非必填
 * @returns {*} 当有phoneNumber时, 验证手机号, 返回布尔值; 当无参数时, 返回正则表达式
 */
hgNews.regExp.phone = function (phoneNumber) {
    var preNumber = [
        '130', '131', '132', '133', '134', '135', '136', '137', '138', '139',
        '140', '141', '142', '143', '144', '145', '146', '147', '148', '149',
        '150', '151', '152', '153', '154', '155', '156', '157', '158', '159',
        '170', '171', '172', '173', '174', '175', '176', '177', '178', '179',
        '180', '181', '182', '183', '184', '185', '186', '187', '188', '189'
    ];
    var reg = '^(' + preNumber.join('|') + ')\\d{8}$';
    if(phoneNumber){

        return new RegExp(reg).test($.trim(phoneNumber.val()));
    } else {
        return reg;
    }
};
